package com.googlecode.marrowboy;

import org.hamcrest.Matcher;
import org.hamcrest.Matchers;

/**
 * Calls to these methods are squirrelled into the real HamCrest MatcherAssert
 * if we're using the Java Agent. So they do all the logging, but none of the
 * exception-throwing.
 * 
 */
public class FakeMarrowBoyAssert {

    /**
     * Shadows declaration in org.hamcrest.MatcherAssert v1.1, 1.2
     */
    public static <T> void assertThat(T actual, Matcher<? super T> matcher) {
        assertThat("", actual, matcher);
    }

    /**
     * Shadows declaration in org.hamcrest.MatcherAssert v1.1, 1.2
     */
    public static <T> void assertThat(String reason, T actual, Matcher<? super T> matcher) {
        
        StackTraceElement element = MarrowBoyAssert.extractStackTraceElementOfOriginalTest();
        String className = element.getClassName();
        String methodName = element.getMethodName();
        
        MarrowBoy.getTestLogger().logAssertion(className, methodName, reason, actual, matcher, matcher.matches(actual));
        
    }

    /**
     * Shadows declaration in org.hamcrest.MatcherAssert v1.2
     */
    public static void assertThat(String reason, boolean assertion) {
        assertThat(reason, assertion, Matchers.is(true));
    }

}
